/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.uml.BasicBehaviors.Behavior;
import edu.pku.sei.modeler.model.uml.Communications.CallConcurrencyKind;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;


/**
 * @generated
 * 
 * modified by zsj
 *
 */
public class BehavioralFeature extends Namespace implements IBehavioralFeature {
	// attributes
	
	protected CallConcurrencyKind concurrency;
	
	protected boolean isAbstract;
	
	
	
	protected boolean isStatic;
	
	protected boolean isLeaf;
	
	
	// references
	
	protected MetaTypedList raisedException;
	
	protected MetaTypedList ownedParameter;
	
	protected MetaTypedList method;
	
	
	
	protected MetaTypedList redefinitionContext;
	
	protected MetaTypedList redefinedElement;
	
	// getters & setters for attributes
	
	public CallConcurrencyKind getConcurrency() {
		return concurrency;
	}
	public void setConcurrency(CallConcurrencyKind newConcurrency) {
		CallConcurrencyKind oldconcurrency = concurrency;
		concurrency = newConcurrency;
		firePropertyChange(ModelPackage.BEHAVIORALFEATURE_CONCURRENCY, oldconcurrency, newConcurrency);
	}
	
	@MethodProperty(
			id = "BEHAVIORALFEATURE_ISABSTRACT",
			catalog = "Model",
			name = ModelPackage.BEHAVIORALFEATURE_ISABSTRACT,
			setter = "setisAbstract"
			)
	
	public boolean getIsAbstract() {
		return isAbstract;
	}
	public void setIsAbstract(boolean newIsAbstract) {
		boolean oldisAbstract = isAbstract;
		isAbstract = newIsAbstract;
		firePropertyChange(ModelPackage.BEHAVIORALFEATURE_ISABSTRACT, oldisAbstract, newIsAbstract);
	}
	
	@MethodProperty(
			id = "BEHAVIORALFEATURE_ISSTATIC",
			catalog = "Model",
			name = ModelPackage.FEATURE_ISSTATIC,
			setter = "setisStatic"
			)
	
	public boolean getIsStatic() {
		return isStatic;
	}
	public void setIsStatic(boolean newIsStatic) {
		boolean oldisStatic = isStatic;
		isStatic = newIsStatic;
		firePropertyChange(ModelPackage.FEATURE_ISSTATIC, oldisStatic, newIsStatic);
	}
	
	@MethodProperty(
			id = "BEHAVIORALFEATURE_ISLEAF",
			catalog = "Model",
			name = ModelPackage.REDEFINABLEELEMENT_ISLEAF,
			setter = "setisLeaf"
			)
	
	public boolean getIsLeaf() {
		return isLeaf;
	}
	public void setIsLeaf(boolean newIsLeaf) {
		boolean oldisLeaf = isLeaf;
		isLeaf = newIsLeaf;
		firePropertyChange(ModelPackage.REDEFINABLEELEMENT_ISLEAF, oldisLeaf, newIsLeaf);
	}
	
	// getters for references
	
	public MetaTypedList getRaisedException() {
		if(raisedException == null) {
			raisedException = new MetaTypedList(Type.class, this, ModelPackage.BEHAVIORALFEATURE_RAISEDEXCEPTION);
		}
		return raisedException;
	}
	
	public MetaTypedList getOwnedParameter() {
		if(ownedParameter == null) {
			ownedParameter = new MetaTypedList(Parameter.class, this, ModelPackage.BEHAVIORALFEATURE_OWNEDPARAMETER);
		}
		return ownedParameter;
	}
	
	public MetaTypedList getMethod() {
		if(method == null) {
			method = new MetaTypedList(Behavior.class, this, ModelPackage.BEHAVIORALFEATURE_METHOD);
		}
		return method;
	}
	
	public MetaTypedList getRedefinitionContext() {
		if(redefinitionContext == null) {
			redefinitionContext = new MetaTypedList(Classifier.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT);
		}
		return redefinitionContext;
	}
	
	public MetaTypedList getRedefinedElement() {
		if(redefinedElement == null) {
			redefinedElement = new MetaTypedList(RedefinableElement.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT);
		}
		return redefinedElement;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.BEHAVIORALFEATURE_CONCURRENCY, concurrency);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.BEHAVIORALFEATURE_ISABSTRACT, isAbstract);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.FEATURE_ISSTATIC, isStatic);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF, isLeaf);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.BEHAVIORALFEATURE_RAISEDEXCEPTION, raisedException);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.BEHAVIORALFEATURE_OWNEDPARAMETER, ownedParameter);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.BEHAVIORALFEATURE_METHOD, method);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, redefinitionContext);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, redefinedElement);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		concurrency = (CallConcurrencyKind)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.BEHAVIORALFEATURE_CONCURRENCY, this);
		
		isAbstract = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.BEHAVIORALFEATURE_ISABSTRACT);
		
		isStatic = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.FEATURE_ISSTATIC);
		
		isLeaf = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF);
		
		// references
		
		this.getRaisedException().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.BEHAVIORALFEATURE_RAISEDEXCEPTION, this));
		
		this.getOwnedParameter().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.BEHAVIORALFEATURE_OWNEDPARAMETER));
		
		this.getMethod().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.BEHAVIORALFEATURE_METHOD, this));
		
		this.getRedefinitionContext().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, this));
		
		this.getRedefinedElement().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.BEHAVIORALFEATURE_CONCURRENCY.equals(featureID)) {
			concurrency = (CallConcurrencyKind)value;
		}
		
		// references
		
		else if(ModelPackage.BEHAVIORALFEATURE_RAISEDEXCEPTION.equals(featureID)) {
			getRaisedException().add(value);
		}
		
		else if(ModelPackage.BEHAVIORALFEATURE_METHOD.equals(featureID)) {
			getMethod().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT.equals(featureID)) {
			getRedefinitionContext().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT.equals(featureID)) {
			getRedefinedElement().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 